package com.example.agriculture.service.impl;

import com.example.agriculture.dao.AdminInforDao;
import com.example.agriculture.entity.AdminInfor;
import com.example.agriculture.service.AdminInforService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (AdminInfor)表服务实现类
 *
 * @author makejava
 * @since 2022-09-11 22:45:45
 */
@Service("adminInforService")
public class AdminInforServiceImpl implements AdminInforService {

    @Resource
    private AdminInforDao adminInforDao;


    @Override
    public AdminInfor adminlogin(String admin_number, String admin_password) {
        return adminInforDao.adminlogin(admin_number,admin_password);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param adminId 主键
     * @return 实例对象
     */
    @Override
    public AdminInfor queryById(Integer adminId) {
        return this.adminInforDao.queryById(adminId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<AdminInfor> queryAllByLimit(int offset, int limit) {
        return this.adminInforDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param adminInfor 实例对象
     * @return 实例对象
     */
    @Override
    public AdminInfor insert(AdminInfor adminInfor) {
        this.adminInforDao.insert(adminInfor);
        return adminInfor;
    }

    /**
     * 修改数据
     *
     * @param adminInfor 实例对象
     * @return 实例对象
     */
    @Override
    public AdminInfor update(AdminInfor adminInfor) {
        this.adminInforDao.update(adminInfor);
        return this.queryById(adminInfor.getAdminId());
    }

    /**
     * 通过主键删除数据
     *
     * @param adminId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer adminId) {
        return this.adminInforDao.deleteById(adminId) > 0;
    }

    @Override
    public int login(String number) {
        return adminInforDao.login(number);
    }
}